import axios from  'axios'
import { ElMessage,ElMessageBox} from 'element-plus'
/**
 *  客房预订列表
 */
export async function reservationList(){
  const respData = await   axios.get("http://localhost:8082/lxhotel/reservationSysServlet.do?oper=list");
  return respData.data.dataparam;
}

/**
 * 入住处理费用计算
 */
export async  function checkInChargeOper(idx){
  const paramObj = { id : idx,oper:'incharge' };
  const respData = await  axios.get("http://localhost:8082/lxhotel/reservationSysServlet.do",{params:paramObj});
  if(respData.data.code ==0){
    // ElMessage.success(respData.data.msg)
    ElMessageBox.confirm(respData.data.msg,'入住信息',
    {
      cancelButtonText: '取消入住',
      confirmButtonText: '确认入住',
      type: 'warning',
      center: true,
      dangerouslyUseHTMLString:true
    }).then( async function(){
      // console.log("参数",idx,respData.data.dataparam.yhcharge,discountactivitiesid:respData.data.dataparam.discountactivitiesid)
      //  ElMessage.success('执行入住处理');
     const paramObj2 = { id : idx, payment: respData.data.dataparam.yhcharge , 
                         discountactivitiesid:respData.data.dataparam.discountactivitiesid, oper:'add'};
     const respData2 =   await  axios.get("http://localhost:8082/lxhotel/checkinsServlet.do",{params:paramObj2});
     if(respData2.data.code == 0){
         ElMessage.success(respData2.data.msg);
     }
    }).catch(function(){
       ElMessage.error('客户放弃入住');
    })
  }
}

